import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey =
  'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC9Tv68ZADwP944N7tXN059MQAh\n' +
  '/NLS2mp5Lel5W4XEh7v9L7cvNrPM8T7C6N+CXKyiBv5izoZHsUPoFizr1qEWzSix\n' +
  'v0eHjSpgP77tBbQ74oSC7Zc3RRdSN2STvZNbddvrIm4FyOYYXQWDCCB3avSDajd0\n' +
  '2PeTQyaP8j5vF4JIgQIDAQAB'

const privateKey = 'MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAL1O/rxkAPA/3jg3u1c3Tn0xACH80tLaankt6XlbhcSHu/0vty8' +
  '2s8zxPsLo34JcrKIG/mLOhkexQ+gWLOvWoRbNKLG/R4eNKmA/vu0FtDvihILtlzdFF1I3ZJO9k1t12+sibgXI5hhdBYMIIHdq9INqN3TY95NDJo/yPm8Xgk' +
  'iBAgMBAAECgYEAtC7+Ev30TrfboRKaw5ampE4BXFgxqfOuKAzlDldoaPjwmznRV6TvWf+8xvOz2Xav8cBKXG1KLe6xPbPtqcOtqkl0iqzd8tn7ttLrDQJZbp2' +
  'yapk5e3hE2PXIDGCnmklUXBqMBj4Ng6KHKQlLXhxpTRNsDRIrdk3deMf26/eWPMkCQQD7Xiozun6ltrKaur7ZL55ZqJrROGMTyRGBVE7CogwMoMn0Spyay341hs' +
  '4mcnZJRVXLt8gSUQ7olqpcldluFz/TAkEAwMwQV6pa4L5cGn+OMZ0Hv/8LRGrCr5fO2unWvl4UPFBkBcudV31g+AQ4VMd1vm1V5rEeNb5szsWua7mXh/g12wJBAJ' +
  'HUdn1eM71l+cZEkxYjRyXS6EZ7BRfkbbBvPeYy5vSoj6GXa7VuW0EofQ7XFwK5I+Y1L/BYcGLFjf56vRLekBsCQGp3hkLTGXJozPX5IK33OJNnJXK3viE3pQyw+' +
  '1yPGX+hKUsmARKSc10i/3SZ3US2nixR/QvSx8V71vE4QRzeDecCQQCC6roac1Ehrzm6scGqNuSU1SIHMXPym6DAbsBM55aBzYz66SfyZQlWTKa4SPAGqX4I+yniPaxg/4XGHym4jP1f'

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

